<?php

namespace App\Admin\Forms\Settings;

use App\Models\SettingModel;
use Encore\Admin\Widgets\Form;
use Illuminate\Http\Request;

class BaseTabForm extends Form
{
    /**
     * The form title.
     *
     * @var string
     */
    public $title = '';

    /**
     * Handle the form request.
     *
     * @param Request $request
     *
     */
    public function handle(Request $request)
    {
        foreach ($request->all() as $k => $v) {
            if ($k == 's') {
                continue;
            }
            SettingModel::updateOrCreate(
                ['key' => $k],
                ['value' => $v]
            );
        }
//      \Illuminate\Support\Facades\Cache::store('file')->forget('settings');
        SettingModel::flushCache();
    }

}
